<?php

class App_Forms_TasksTableParams extends App_Forms_TemplateAbstract implements App_Interfaces_IForms {
	
	/**
	 * Nome do servidor
	 *
	 * @var string
	 */
	protected $serverName;
	
	/**
	 * Tipo de adaptador
	 *
	 * @var string
	 */
	protected $dbAdapter;
	
	/**
	 * Nome ou Ip do servidor
	 *
	 * @var string
	 */
	protected $host;
	
	/**
	 * Nome do utilizador para autenticar a BD
	 *
	 * @var string
	 */
	protected $username;
	
	/**
	 * Palavra passe
	 *
	 * @var string
	 */
	protected $password;
	
	/**
	 * Nome da base de dados
	 *
	 * @var string
	 */
	protected $dbName;
	
	/**
	 * Botão de envio
	 *
	 * @var mixed
	 */
	protected $submit;
	

	
	
	/**
	 * Formulário
	 * 
	 * @return Zend_Form 
	 */
	public static function getForm() {
	
		$serverName = new Zend_Form_Element_Text('webhost');
		$serverName->setLabel('Nome do Servidor:')
				   ->setRequired(true)
				   ->setAttrib('class', self::CLASS_BOX_TYPE_SMALL)
				   ->addErrorMessage(self::ERR_EMPTY_FIELD);

		$dbAdapter = new Zend_Form_Element_Select('adapter');
		$dbAdapter->setLabel('Adaptador Base de Dados:')
				  ->setRequired(TRUE)
				  ->setAttrib('class', self::CLASS_BOX_TYPE_SMALL)
				  ->addErrorMessage(self::ERR_EMPTY_FIELD)
				  ->addMultiOptions(array(
				  							''=>'Escolha o adaptador:',
				  							'mysqli'=>'MySQLi',
				  							'pdo_mssql'=>'MS SQL Server',
				  							'pdo_mysql'=>'PDO MySQL',
				  							'pdo_pgsql'=>'Postgre SQL',
				  							'pdo_sqlite'=>'SQLite'
				  					));
				  					
		$host = new Zend_Form_Element_Text('host');
		$host->setLabel('IP ou DNS do servidor base de dados:')
			 ->setRequired(TRUE)
			 ->setAttrib('class', self::CLASS_BOX_TYPE_SMALL)
			 ->addErrorMessage(self::ERR_EMPTY_FIELD);	  					
				  					
		$username = new Zend_Form_Element_Text('username');
		$username->setLabel('Utilizador base de dados:')
				 ->setRequired(TRUE)
				 ->setAttrib('class', self::CLASS_BOX_TYPE_SMALL)
				 ->addErrorMessage(self::ERR_EMPTY_FIELD);
				 
		$password = new Zend_Form_Element_Text('password');
		$password->setLabel('Palavra-passe:')
				 ->setRequired(TRUE)
				 ->setAttrib('class', self::CLASS_BOX_TYPE_SMALL)
				 ->addErrorMessage(self::ERR_EMPTY_FIELD);
				 
		$dbName = new Zend_Form_Element_Text('dbname');
		$dbName->setLabel('Nome da base de dados:')
			   ->setRequired(TRUE)
			   ->setAttrib('class', self::CLASS_BOX_TYPE_SMALL)
			   ->addErrorMessage(self::ERR_EMPTY_FIELD);
		
	
		$submit = new Zend_Form_Element_Submit('submit');
		$submit->setLabel('Criar / Alterar');
		
		$form = new Zend_Form();
		$form->setAction('/admin/newlogindb')
			 ->setMethod('post')
			 ->addElements(array($serverName, $dbAdapter, $host, $username, $password, $dbName, $submit));
			 
		return $form;
	}
}

?>